package it.polimi.digitalstate.webbeans;

import it.polimi.digitalstate.dto.MembershipDTO;
import it.polimi.digitalstate.dto.PartyDTO;
import it.polimi.digitalstate.manager.PartyManagerLocal;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
/**
 * PartyViewBean show the characteristics of one party, and its list of member
 *
 */
@ManagedBean(name="partyViewBean")
@RequestScoped
public class PartyViewBean {
	@EJB
	private PartyManagerLocal ejb;
	private PartyDTO party;
	private MembershipDTO[] member;
	@ManagedProperty("#{param.partyname}")
	private String partyname;

	public String getPartyname() {
		return partyname;
	}
	public void setPartyname(String partyname) {
		this.partyname = partyname;
	}
	@PostConstruct
	public void init(){
		System.out.println("partyname: " + partyname);
		party=ejb.getPartyByName(partyname);
		System.out.println("partyisnull: " + party==null);
		member=ejb.getListOfMember(party);
		System.out.println("N OF MEMBER " + member.length);
	}
	public MembershipDTO[] getMember() {
		return member;
	}
	public void setMember(MembershipDTO[] member) {
		this.member = member;
	}
	public PartyDTO getParty() {
		return party;
	}
	public void setParty(PartyDTO party) {
		this.party = party;
	}	
}
